﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="frmPanelDeControl.aspx.cs" Inherits="frmPanelDeControl" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    
       <h1> Panel de Control de Usuario</h1>
       <p> 
            &nbsp;<asp:Panel ID="Panel1" runat="server" Height="190px" Visible="False">
                <table style="width:100%;">
                    <tr>
                        <td>
                            &nbsp;</td>
                        <td>
                            &nbsp;</td>
                        <td>
                            &nbsp;</td>
                        <td>
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td style="font-weight: bold" valign="bottom">
                            Registrar Nuevo Usuario</td>
                        <td style="font-weight: bold" valign="bottom">
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;</td>
                        <td style="font-weight: bold" valign="bottom">
                            &nbsp; Listado de Usuarios Existentes:</td>
                        <td>
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td valign="top">
                            Nombre:<br />
                            <asp:TextBox ID="TextBox3" runat="server" Height="21px" 
                                ontextchanged="TextBox3_TextChanged" Width="189px"></asp:TextBox>
                            <br />
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                                ControlToValidate="TextBox3" ErrorMessage="Ingrese un nombre de usuario" 
                                ForeColor="#FF3300" Font-Bold="True"></asp:RequiredFieldValidator>
                            <br />
                            Contraseña:<br />
                            <asp:TextBox ID="TextBox4" runat="server" Height="20px" 
                                ontextchanged="TextBox4_TextChanged" Width="189px"></asp:TextBox>
                            <br />
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" 
                                ControlToValidate="TextBox4" 
                                ErrorMessage="Ingrese una contraseña" ForeColor="#CC3300" Font-Bold="True"></asp:RequiredFieldValidator>
                            <br />
                            Nivel de Acceso:<br />
                            <asp:DropDownList ID="DropDownList2" runat="server" 
                                DataSourceID="SqlDataSource1" DataTextField="nombre_cuenta" 
                                DataValueField="cod_cuenta" Height="26px" Width="191px">
                            </asp:DropDownList>
                        </td>
                        <td valign="top">
                            &nbsp;</td>
                        <td valign="top">
                            <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
                                AllowSorting="True" AutoGenerateColumns="False" BackColor="White" 
                                BorderColor="White" BorderStyle="Ridge" BorderWidth="2px" CellPadding="3" 
                                CellSpacing="1" DataKeyNames="id_usr" DataSourceID="SqlDataSource2" 
                                EmptyDataText="No hay registros de datos para mostrar." GridLines="None">
                                <Columns>
                                    <asp:CommandField ButtonType="Image" 
                                        CancelImageUrl="~/Img/ico_chico_cancelar.png" CausesValidation="False" 
                                        DeleteImageUrl="~/Img/ico_chico_eliminar.png" 
                                        EditImageUrl="~/Img/ico_chico_edicion.png" HeaderText="Acciones" 
                                        ShowDeleteButton="True" ShowEditButton="True" 
                                        UpdateImageUrl="~/Img/ico_chico_ok.png" />
                                    <asp:BoundField DataField="id_usr" HeaderText="id_usr" ReadOnly="True" 
                                        SortExpression="id_usr" />
                                    <asp:BoundField DataField="nombre" HeaderText="nombre" 
                                        SortExpression="nombre" />
                                    <asp:BoundField DataField="pass" HeaderText="pass" SortExpression="pass" />
                                    <asp:BoundField DataField="tipo_cuenta" HeaderText="tipo_cuenta" 
                                        SortExpression="tipo_cuenta" />
                                </Columns>
                                <FooterStyle BackColor="#C6C3C6" ForeColor="Black" />
                                <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#E7E7FF" />
                                <PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" />
                                <RowStyle BackColor="#DEDFDE" ForeColor="Black" />
                                <SelectedRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" />
                                <SortedAscendingCellStyle BackColor="#F1F1F1" />
                                <SortedAscendingHeaderStyle BackColor="#594B9C" />
                                <SortedDescendingCellStyle BackColor="#CAC9C9" />
                                <SortedDescendingHeaderStyle BackColor="#33276A" />
                            </asp:GridView>
                            <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
                                ConnectionString="<%$ ConnectionStrings:BD_SAFA_FINALConnectionString %>" 
                                DeleteCommand="DELETE FROM [T_Login] WHERE [id_usr] = @id_usr" 
                                InsertCommand="INSERT INTO [T_Login] ([nombre], [pass], [tipo_cuenta]) VALUES (@nombre, @pass, @tipo_cuenta)" 
                                ProviderName="<%$ ConnectionStrings:BD_SAFA_FINALConnectionString.ProviderName %>" 
                                SelectCommand="SELECT [id_usr], [nombre], [pass], [tipo_cuenta] FROM [T_Login]" 
                                UpdateCommand="UPDATE [T_Login] SET [nombre] = @nombre, [pass] = @pass, [tipo_cuenta] = @tipo_cuenta WHERE [id_usr] = @id_usr">
                                <DeleteParameters>
                                    <asp:Parameter Name="id_usr" Type="Int32" />
                                </DeleteParameters>
                                <InsertParameters>
                                    <asp:Parameter Name="nombre" Type="String" />
                                    <asp:Parameter Name="pass" Type="String" />
                                    <asp:Parameter Name="tipo_cuenta" Type="String" />
                                </InsertParameters>
                                <UpdateParameters>
                                    <asp:Parameter Name="nombre" Type="String" />
                                    <asp:Parameter Name="pass" Type="String" />
                                    <asp:Parameter Name="tipo_cuenta" Type="String" />
                                    <asp:Parameter Name="id_usr" Type="Int32" />
                                </UpdateParameters>
                            </asp:SqlDataSource>
                            <br />
                            <br />
                            <asp:Label ID="Label2" runat="server" Font-Bold="True" ForeColor="#0066FF"></asp:Label>
                        </td>
                        <td>
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td class="style2">
                            <br />
                        </td>
                        <td class="style2">
                            &nbsp;</td>
                        <td class="style2">
                            &nbsp;</td>
                        <td class="style2">
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:Button ID="Button6" runat="server" Height="28px" onclick="Button2_Click" 
                                Text="Registrar nuevo usuario" Width="177px" />
                            <br />
                            <br />
                            <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                                ConnectionString="<%$ ConnectionStrings:BD_SAFA_FINALConnectionString %>" 
                                SelectCommand="SELECT * FROM [T_Cuentas]"></asp:SqlDataSource>
                            <br />
                        </td>
                        <td>
                            &nbsp;</td>
                        <td valign="top">
                            <asp:Button ID="Button7" runat="server" CausesValidation="False" Height="28px" 
                                onclick="Button4_Click" Text="Regresar" Width="175px" />
                        </td>
                        <td>
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td>
                            <br />
                        </td>
                        <td>
                            &nbsp;</td>
                        <td>
                            &nbsp;</td>
                        <td>
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td>
                            &nbsp;</td>
                        <td>
                            &nbsp;</td>
                        <td>
                            &nbsp;</td>
                        <td>
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td>
                            &nbsp;</td>
                        <td>
                            &nbsp;</td>
                        <td>
                            &nbsp;</td>
                        <td>
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td>
                            &nbsp;</td>
                        <td>
                            &nbsp;</td>
                        <td>
                            &nbsp;</td>
                        <td>
                            &nbsp;</td>
                    </tr>
                </table>
                <br />
            </asp:Panel>
        <p> &nbsp;</p>
</asp:Content>

